/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package treccontextsug;

import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.json.simple.JSONObject;
import org.json.simple.parser.ParseException;

/**
 *
 * @author manzato
 */
public class ContextsSet extends Parser {
    private ArrayList<Context> contexts;
    
    public ContextsSet(String contextsFile) {
        super(contextsFile);
        this.contexts = new ArrayList();
    }

    @Override
    public void readJSON() throws IOException, ParseException {
        jsonObject = (JSONObject) parser.parse(new FileReader(filename));
        Set<String> set = jsonObject.keySet();
        
        for(String s : set) {
            JSONObject j = (JSONObject)jsonObject.get(s);
            double lati = (double)j.get("lat");
            double longi = (double)j.get("long");
            String city = (String)j.get("city");
            String state = (String)j.get("state");
            Context c = new Context(s, lati, longi, city, state);
            contexts.add(c);
        }
    }
    
    public ArrayList<Context> getAllContexts() {
        return contexts;
    }
}
